home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / ms_sh21s.zip / SH210 / INCLUDE / SYS / DIRENT.H next >
C/C++ Source or Header  |  1992-12-14  |  1KB  |  49 lines

  1. /* <sys/dirent.h> -- file system independent directory entry (SVR3) */
  2. #ifndef _SYS_DIRENT_H
  3. #define _SYS_DIRENT_H
  4.  
  5. #ifndef MSDOS
  6. #define    MAXNAMLEN    512    /* maximum filename length        */
  7. #else
  8. #define    MAXNAMLEN    13    /* maximum filename length        */
  9. #endif
  10.  
  11. #ifndef NAME_MAX
  12. #define    NAME_MAX    (MAXNAMLEN - 1)
  13. #endif
  14.  
  15. struct dirent            /* data from getdents()/readdir()    */
  16. {
  17.     ino_t    d_ino;        /* inode number of entry        */
  18.     off_t    d_off;        /* offset of disk directory entry    */
  19.     ushort    d_reclen;    /* length of this record        */
  20. #ifndef MSDOS
  21.     char    d_name[1];    /* name of file                */
  22. #else
  23.     char    d_name[MAXNAMLEN + 1];
  24. #endif
  25. };
  26.  
  27. #ifdef BSD_SYSV            /* (e.g., when compiling getdents.c)    */
  28. extern struct dirent    __dirent;    /* (not actually used) */
  29.  
  30.                 /* The following is portable, although    */
  31.                 /* rather silly.            */
  32. #define    DIRENTBASESIZ        (__dirent.d_name - (char *)&__dirent.d_ino)
  33.  
  34. #else
  35.  
  36. /* The following nonportable ugliness could have been avoided by defining
  37.  * DIRENTSIZ and DIRENTBASESIZ to also have (struct dirent *) arguments.
  38.  * There shouldn't be any problem if you avoid using the DIRENTSIZ() macro.
  39.  */
  40.  
  41. #define    DIRENTBASESIZ        (((struct dirent *)0)->d_name \
  42.                 - (char *)&((struct dirent *)0)->d_ino)
  43. #endif
  44.  
  45. #define    DIRENTSIZ(namlen)    ((DIRENTBASESIZ + sizeof(long) + (namlen)) \
  46.                 / sizeof(long) * sizeof(long))
  47.  
  48. #endif
  49.